<template>
  <div>
    <Search > 添加分类 </Search>

    <Table
      :data="list"
      border
      row-key="cat_id"
      :total="total"
      :cols="cols"
      @change="getcateList()"
      v-model="queryModel"
    >
      <template v-slot:action="{ row }">
        <el-button
          type="primary"
          size="mini"
          icon="el-icon-edit"
          >编辑</el-button
        >
        <el-button
          type="danger"
          size="mini"
          icon="el-icon-delete"
          >删除</el-button
        >
      </template>
    </Table>
  </div>
</template>

<script>
import { queryMixin } from "@/mixin/baseMixin";
import { cateList } from "api/goods";
export default {
  mixins: [queryMixin],
  name: "categories",
  data() {
    return {
      cols: [
        {
          type: "index",
          title: "#",
        },
        {
          title: "分类名称",
          name: "cat_name",
        },
        {
          title: "是否有效",
          name: "cat_deleted",
        },
        {
          title: "排序",
          slot: "sort",
        },
        {
          title: "操作",
          slot: "action",
        },
      ],
      /**
       * 分类数据
       */
      model: {},
    };
  },
  methods: {
    async getcateList() {
      try {
        this.queryloading = true;
        const { result, total } = await cateList(this.queryModel);
        this.total = total;
        this.list = result;
      } catch (error) {
        console.log(error);
      }
      this.queryloading = false;
    },
  },
  created() {
    this.getcateList();
  },
};
</script>

<style lang="scss" scoped>
</style>